<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <ul>

    </ul>
    <script>
        /**
         *  1. 同步任务
         *  2. 清空微任务队列
         *  3. 执行DOM渲染
         *  4. 执行宏任务
         * 
         */
        let oUl = document.querySelector('ul');

        let li1 = document.createElement('li');
        li1.innerHTML = 111;
        let li2 = document.createElement('li');
        li2.innerHTML = 222;
        let li3 = document.createElement('li');
        li3.innerHTML = 333;

        oUl.appendChild(li1);
        oUl.appendChild(li2);
        oUl.appendChild(li3);

        // alert(oUl.children.length);

        setTimeout(()=>{
            console.log(oUl.children.length);
            alert('宏任务');
        })

        Promise.resolve('ok').then(value=>{
            console.log(oUl.children.length);
            alert('微任务');
        })


    </script>
</body>
</html>